package com.yinhe.music.yhmusic.start;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;

import com.yinhe.music.yhmusic.R;
import com.yinhe.music.yhmusic.base.BaseActivity;
import com.yinhe.music.yhmusic.cache.CacheManager;
import com.yinhe.music.yhmusic.main.MainActivity;
import com.yinhe.music.yhmusic.utils.UmengEventUtils;

import butterknife.BindView;
import butterknife.ButterKnife;

public class SelectFavActivity extends BaseActivity implements View.OnClickListener {

    @BindView(R.id.tv_skip)
    TextView tvSkip;
    @BindView(R.id.style_zang)
    FrameLayout styleZang;
    @BindView(R.id.style_hua)
    FrameLayout styleHua;
    @BindView(R.id.img_zang_background)
    ImageView background1;
    @BindView(R.id.img_hua_background)
    ImageView background2;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_select_fav);
        ButterKnife.bind(this);
        bindListener();
    }

    private void bindListener() {
        tvSkip.setOnClickListener(this);
        styleHua.setOnClickListener(this);
        styleZang.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.tv_skip:
                startMain();
                break;
            case R.id.style_hua:
                setSelect(background2);
                break;
            case R.id.style_zang:
                setSelect(background1);
                break;
            default:
                break;
        }
    }


    private void startMain() {
        Intent intent = new Intent(this, MainActivity.class);
        startActivity(intent);
        finish();
    }

    private void setSelect(ImageView select) {
        select.setBackground(getResources().getDrawable(R.drawable.ic_fav_selected));
        if (select == background1) {
            UmengEventUtils.clickStyle(this,0);
            CacheManager.getInstance().setTypeLangId(0);
        } else {
            UmengEventUtils.clickStyle(this,1);
            CacheManager.getInstance().setTypeLangId(1);
        }
        startMain();
    }
}
